/******************************************************************************
 * @File name   :      PackageDefinitionDaoImpl.java
 *
 * @Author      :      JIZHANGS
 *
 * @Date        :      Jul 22, 2015
 *
 * @Copyright Notice: 
 * Copyright (c) 2015 Capgemini, Inc. All  Rights Reserved.
 * This software is published under the terms of the Capgemini Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who         Version        Comments
 * Jul 22, 2015 3:25:52 PM        JIZHANGS     1.0            Initial Version
 *****************************************************************************/
package com.cap.bts.crmdp.dealer.purchase.dao.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.cap.bts.crmdp.dealer.purchase.dao.IPackageDefinitionDao;
import com.cap.bts.crmdp.dealer.purchase.domain.PackageDefinition;
import com.cap.bts.framework.common.dao.impl.BaseDaoImpl;
import com.cap.bts.framework.common.exception.AppException;

/**
 *
 */
@Repository("packageDefinitionDao")
public class PackageDefinitionDaoImpl extends BaseDaoImpl<PackageDefinition, Long> implements IPackageDefinitionDao {

    /**
     * @Date        :      Jul 22, 2015
     * @param clazz
     */
    @Inject
    public PackageDefinitionDaoImpl(@Value("com.cap.bts.crmdp.dealer.purchase.domain.PackageDefinition") Class<PackageDefinition> clazz) {
        super(clazz);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Jul 22, 2015
     * @see com.cap.bts.crmdp.dealer.purchase.dao.IPackageDefinitionDao#getAllPackageDefinitionList()
    **/
    @Override
    public List<PackageDefinition> getAllPackageDefinitionList() throws AppException {
        return  super.getListByQuery("select a from PackageDefinition a left join a.cardDefinition where a.status =1 order by a.code");
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      Aug 23, 2015
     * @see com.cap.bts.crmdp.dealer.purchase.dao.IPackageDefinitionDao#getPackageDefinitionInfoById(java.lang.Long)
    **/
    @Override
    public PackageDefinition getPackageDefinitionInfoById(Long id) throws AppException {
        return super.findById(id);
    }

    /**
     * {@inheritDoc} 
     * overridden:
     * @Date        :      2015年11月17日
     * @see com.cap.bts.crmdp.dealer.purchase.dao.IPackageDefinitionDao#getPackageDefinitionListByCode(java.lang.String)
    **/
    @Override
    public List<PackageDefinition> getPackageDefinitionListByCode(String code) throws AppException {
        String sql = "select * from tm_crm_package_definition a"
            + " where a.CODE = " + code;
        return this.getListByNativeQuery(sql);
    }

}

